# coding:UTF-8
from __future__ import unicode_literals

from django.db import models
from mongoengine import *
from datetime import datetime

# 连接数据库
# connect('blog', host='127.0.0.1:30001')  # 连接本地blog数据库
# 如需验证和指定主机名
# connect('blog', host='192.168.3.1', username='root', password='1234')


class Categories(Document):
    """定义分类文档：继承Document类,为普通文档"""
    name = StringField(max_length=30, required=True)
    artnum = IntField(default=0, required=True)
    date = DateTimeField(default=datetime.now(), required=True)

    meta = {'db_alias': "default", 'collection': 'mng_category', 'indexes': ['name']}

    def __unicode__(self):
        return '%s: %s' % (self.name, self.artnum)
